<%-- 
    Document   : index
    Created on : Mar 17, 2012, 8:27:06 PM
    Author     : ALEXXX
--%>

<%@page import="edu.os.dao.zakharov.Facade"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page errorPage="error.jsp"%>

<%! private Facade facade = null;

    public void jspInit() {
        try {
            facade = Facade.getInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
%>  


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Online Store</title>
    </head>
    <body>
        <center><h1>Добро пожаловать на наш сайт!</h1></center>
        <br><br>
        <center><font size="5">Зарегистрируйтесь пожалуйста</font></center>
        <br><br>
        <form method="get" name="MainForm" action="index.jsp">

            Фамилия: <input type="text" name="surname"/>
            <br><br>
            Имя: <input type="text" name="name"/>
            <br><br>
            Отчество: <input type="text" name="patronymic"/>
            <br><br>
            E-mail: <input type="text" name="email"/>
            <br><br>
            Страна: <input type="text" name="country"/>
            <br><br>
            Город: <input type="text" name="city"/>
            <br><br>
            Логин: <input type="text" name="login"/>
            <br><br>
            Пароль: <input type="text" name="password"/>
            <br><br>
            <center> <input type="submit" name="register" value="Зарегистрировать"> </center>
            <br><br>

        </form>

        <%
            if (request.getParameter("register") == null) {
            } else {
                try {
                    facade.registerUser(request.getParameter("surname"), 
                            request.getParameter("name"), request.getParameter("patronymic"),
                            request.getParameter("email"), request.getParameter("country"),
                            request.getParameter("city"), request.getParameter("login"),
                            request.getParameter("password"));
                } catch (Exception e) {
                    throw new Exception("Exception: " + e.getMessage(), e);
                }
            }
        %>

    </body>
</html>
